package leetcode.hot100;

/**
 * 11.盛最多的水
 */
public class MaxWater {
    public static void main(String[] args) {
        int[] nums1 = {1,8,6,2,5,4,8,3,7};
        int[] nums = {1,1};
        int maxArea = new MaxWater().maxWater(nums);
        System.out.println(maxArea);
    }
    public int maxWater(int[] nums) {
        int i = 0;
        int j = nums.length - 1;
        int res = 0;
        while (i < j) {
            if (nums[i] >= nums[j]) {
                res = Math.max(res, nums[j]*(j-i));
                j--;
            } else {
                res = Math.max(res, nums[i]*(j-i));
                i++;
            }
        }
        return res;
    }
}
